/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package researchgrants.parts.pi.filters;

import researchgrants.parts.pi.*;
import java.util.Iterator;

/**
 * This class actually filters a list of GrantRequest (GrantRequestList) using a given filter
 * @author ohad
 */
public class PisListFilters {
    public static void filterByFreeText(PisList list, String text) {
        filter(list, new PiFilterFreeText(text));
    }
    
    
    private static void filter(PisList before, PiFilter piFilter) {
        for (Iterator<Pi> it = before.iterator(); it.hasNext();) {
            Pi pi = it.next();
            if (piFilter.isFiltered(pi)) {
                it.remove();
            }
        }
    }
}
